//
//  MyWidgetNavBar.swift
//  TimMusic
//
//  Created by nkl on 2024/10/24.
//

import Foundation

class MyWidgetNavBar: UIView {
    lazy var backButton: UIButton = {
        let btn = UIButton()
        btn.setImage(UIImage.init(named: "ic_back"), for: .normal)
        return btn
    }()
    
    lazy var titleLabel: UILabel = .simpleLabel(text: "My Widgets", font: .systemFont16, color: .white)
    
    lazy var manageButton: UIButton = {
        let btn = UIButton()
        btn.titleLabel?.font = .systemFont14
        btn.layer.cornerRadius = 10
        btn.layer.borderWidth = 1
        btn.layer.borderColor = UIColor.white.withAlphaComponent(0.15).cgColor
        btn.setTitle("Manage", for: .normal)
        btn.setTitle("Done", for: .selected)
        btn.setTitleColor(.white.withAlphaComponent(0.4), for: .normal)
        btn.setTitleColor(.red, for: .selected)
        return btn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        addChildren()
        makeConstraints()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func addChildren(){
        addSubview(backButton)
        addSubview(titleLabel)
        addSubview(manageButton)
    }
 
    func makeConstraints(){
        backButton.snp.makeConstraints { make in
            make.leading.equalToSuperview().offset(16)
            make.width.height.equalTo(24)
            make.centerY.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { make in
            make.center.equalToSuperview()
        }
        
        manageButton.snp.makeConstraints { make in
            make.trailing.equalToSuperview().offset(-16)
            make.centerY.equalToSuperview()
            make.height.equalTo(20)
            make.width.equalTo(80)
        }
    }
}
